package com.septimus.portal.service;

import org.apache.log4j.Logger;

import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import com.septimus.portal.model.User;

@Stateless
public class UserRegistration {

	 	@Inject
	    private Logger log;

	    @Inject
	    private EntityManager em;

	    @Inject
	    private Event<User> userEventSrc;

	    public User register(User user) throws Exception {
	        log.info("\n\nRegistering " + user.getName());
	        User userRegistred = em.merge(user);
	        userEventSrc.fire(user);
	        return userRegistred;
	    }
}
